package se.webbzon.boltzmann.game.event;

import se.webbzon.boltzmann.camera.TargetableCamera;
import se.webbzon.boltzmann.game.sequence.Sequence;
import se.webbzon.oschi01.worldarea.WorldArea;
import se.webbzon.oschi01.worldobject.WorldObject;
import se.webbzon.oschi01.worldobject.WorldStaticObject;

public class SetCameraTargetEvent extends AbstractTargetEvent {
	
	// The camera to target (null = reset)
	private final WorldObject binding;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public SetCameraTargetEvent(Sequence sequence, String[] arguments, WorldObject binding) {
		super(sequence,arguments);
		this.binding = binding;
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override protected void onBegin(WorldArea world) {
		WorldObject target = getTarget();
		if (	binding instanceof TargetableCamera && 
				target instanceof WorldStaticObject) {
			((TargetableCamera) binding).setTarget((WorldStaticObject) target);
		}
		end();
	}

	@Override protected void onEnd() {};

}
